import request from '../../request/request.js'
Page({

  
  data: {
    swiperList:[],
    active: 0,
    commentList:[],
    coachInfo:'',
    coachRecord:''
  },
  onChange(event) {
    // event.detail 的值为当前选中项的索引
    if(event.detail===1){
      wx.redirectTo({
        url: '../t_course/t_course'
      });
    }
    if(event.detail===2){
      wx.redirectTo({
        url: '../t_user/t_user'
      });
    }   
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let coachInfo = wx.getStorageSync("coachInfo");
    this.setData({coachInfo:coachInfo})
    this.getSwiperList();
    this.getCommentList();
    this.getCoachRecord();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },
  getSwiperList(){
    request({
      url:'system/swiper'
    }).then(res=>{
      this.setData({
        swiperList:res.data.data
      })
    }).catch(err=>{})
  },
  getCommentList(){
    let that = this
    request({
      url:'coach/comment/list',
      method:'post',
      data:{
        id:that.data.coachInfo.id,
      }
    }).then(res=>{
      if(res.data.success){
        that.setData({
          commentList:res.data.data
        })
      }
    })
  },
  getCoachRecord(){
    let that = this
    request({
      url:'coach/record',
      method:'post',
      data:{
        id:that.data.coachInfo.id,
      }
    }).then(res=>{
      if(res.data.success){
        that.setData({
          coachRecord:res.data.data
        })
      }
    })
  }
})